今天出門上班前確認昨天晚上的訓練結果,一則以喜一則以憂呀~有訓練出數值,但準確率爆低QQ
代表模型沒有真正學習到資料勒~今天繼續Debug
1.AlexNet目前運算結果
2.競賽資料Debug紀錄
目前進度:AexNet模型全部資料訓練結果,準確率(Accuracy)約為2%
# Debug1~Debug3在昨日鐵人文章(D20)
total_step = len(train_loader)
for epoch in range(num_epochs):
print("Epoch={}".format(epoch))
for i, (images, labels_tensor) in enumerate(train_loader):
print("=================="+"Train"+"==================")
print("train_batch_number: {}".format(i))
# Move tensors to the configured device
images = images.to(device)
labels = labels_tensor.to(device)
labels = labels.squeeze(1) # Debug_1
# Forward pass
outputs = model_alexnet(images)
labels = labels.type(torch.LongTensor) # Debug_2
loss = criterion(outputs, labels)
# Backward and optimize
optimizer.zero_grad()
loss.backward()
optimizer.step()
print("==== Finish an Train_batch ====")
now = datetime.datetime.now()
print(now)
print ('Epoch [{}/{}], Step [{}/{}], Loss: {:.4f}'.format(epoch+1, num_epochs, i+1, total_step, loss.item()))
# Validation
print("=================="+"Validation"+"==================")
with torch.no_grad():
correct = 0
total = 0
for images, labels in val_loader:
print("Validation_batch_number: {}".format(i))
images = images.to(device)
labels = labels.squeeze(1) # Debug_1
outputs = model_alexnet(images)
labels = labels.type(torch.LongTensor) # Debug_2
_, predicted = torch.max(outputs.data, 1)
print("predicted={}, labels={}".format(predicted, labels))
total += labels.size(0)
correct += (predicted == labels).sum().item() # Debug_4
del images, labels, outputs
print("==== Finish an Validation_batch ====")
print('Accuracy of the network on the validation images: {} %'.format(100 * correct / total))
print("==============================Finish an epoch==============================")
Validation
Test
上述問題(上圖紅框處): 模型給出的預測值的tensor元素數值都為0。(Debug_4)
關於上述程式碼還有需解決的部分:
Note: Debug1~Debug3在昨日鐵人文章
目前進度:處理中
目前進度:處理中
今天花蠻多時間更新安裝,但jupyter目前還是無法運行gpu(下圖)
但cmd的ipython可以運行(下圖)
對AlexNet模型於競賽資料實作仍在Debug中~
Keep Debugging!!!
心得小語:
今天是沒甚麼結果的一天QQ 只能繼續debug了,希望明天有好結果能分享,如果還是沒有,那..那...那只能在多加一天了
今日工時50min*3
不順利的日子讓你變得更強壯
The hard days are what make you stronger.